package _15_generics._15_8;

/**
 * 编译器可以确保类型标签匹配泛型参数
 */
public class _01_ClassTypeCapture<T> {
    Class<T> kind;
    public _01_ClassTypeCapture(Class<T> kind){
        this.kind = kind;
    }
    public boolean f(Object obj){
        return kind.isInstance(obj);
    }

    public static void main(String[] args) {
        _01_ClassTypeCapture ctt1 = new _01_ClassTypeCapture(Building.class);
        System.out.println(ctt1.f(new Building()));
        System.out.println(ctt1.f(new House()));
        _01_ClassTypeCapture ctt2 = new _01_ClassTypeCapture(House.class);
        System.out.println(ctt2.f(new Building()));
        System.out.println(ctt2.f(new House()));
    }
}

class Building{}
class House extends Building{}
